//
//  TYZSuspendTopPauseCollectionViewController.m
//  AVfoundationDemo
//
//  Created by TangBin on 2019/8/22.
//  Copyright © 2019 TangBin. All rights reserved.
//

#import "TYZSuspendTopPauseCollectionViewController.h"

@interface TYZSuspendTopPauseCollectionViewController ()

@end

@implementation TYZSuspendTopPauseCollectionViewController

- (void)initWithBasicCollectionView
{
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.minimumLineSpacing = 5.0;
    //    flowLayout.minimumLineSpacing = 5.0;
    [flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
    self.flowLayout = flowLayout;
    static CGFloat statusHeight;
    static CGRect bounds;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        bounds = [[UIScreen mainScreen] bounds];
        statusHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
    });
    CGFloat navBarHeight = self.navigationController.navigationBar.bounds.size.height;
    //    NSLog(@"statusHeight=%.2f; navBarHeight=%.2f", statusHeight, navBarHeight);
    CGRect frame = CGRectMake(0.0f, 0.0f, bounds.size.width, bounds.size.height - statusHeight - navBarHeight);
    
    self.baseCollectionView = [[TYZPageCollectionView alloc] initWithFrame:frame collectionViewLayout:flowLayout];
    self.baseCollectionView.backgroundView = nil;
    self.baseCollectionView.backgroundColor = [UIColor clearColor];
    self.baseCollectionView.alwaysBounceVertical = YES;
    self.baseCollectionView.delegate = self;
    self.baseCollectionView.dataSource = self;
    
    
    if (@available(iOS 11.0, *))
    {
        self.baseCollectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    
    [self.baseCollectionView registerClass:[TYZBaseCollectionViewCell class] forCellWithReuseIdentifier:[TYZBaseCollectionViewCell cellIdentifier]];
    
    //    [self.baseCollectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"dd"];
    
    
    [self.view addSubview:self.baseCollectionView];
    
    
    
    // 2.上拉加载更多(进入刷新状态就会调用self的doMoreRefreshData)
    MJRefreshBackNormalFooter *footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(doMoreRefreshData)];
//    footer.ignoredScrollViewContentInsetBottom = ignoredScrollViewContentInsetBottom_;
    [footer setTitle:@"上拉加载更多数据" forState:MJRefreshStateIdle];
    [footer setTitle:@"松开加载更多数据" forState:MJRefreshStatePulling];
    [footer setTitle:@"正在加载中" forState:MJRefreshStateRefreshing];
    self.baseCollectionView.mj_footer = footer;
    
}
@end
